package com.example.protestgps;


import org.json.JSONArray;
import org.json.JSONObject;

import com.google.android.gms.maps.GoogleMap;
import com.google.android.gms.maps.SupportMapFragment;
import com.google.android.gms.maps.model.LatLng;

import android.content.Context;
import android.location.LocationManager;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.util.Log;

public class GetPointRouteNormal extends FragmentActivity {
	
	private LocationManager lm;
	GoogleMap myMap;
	public Context con;
	int getvalueintent;
	int positionclick;
	String getvalue;
	double latchange;
	double lngchange;
	LatLng start2;
	double deslat1; 
	double deslng1;
	
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.getmapnormal);
		// TODO Auto-generated method stub
		
		getvalueintent = getIntent().getIntExtra("position",positionclick);
		getvalue = getIntent().getStringExtra("value");
		
		Log.d("lsv1", ""+getvalueintent);
		Log.d("getvalue", ""+getvalue);	
		lm = (LocationManager) getSystemService(LOCATION_SERVICE);
		con = new MainActivity();
		GetLocation local = new GetLocation(lm, this, myMap);
		latchange = local.GetLat();
		lngchange = local.GetLng();
		start2 = new LatLng(latchange, lngchange);
		SupportMapFragment mySupport = (SupportMapFragment) getSupportFragmentManager()
				.findFragmentById(R.id.map_canvas);
		myMap = mySupport.getMap();
		myMap.setMyLocationEnabled(true);
        CallHTTP(latchange,lngchange);
		posternormal(latchange, latchange);				
		
	}
	
	
	
	
	
	
	 public void CallHTTP(double curlat,double curlng) {
		    AsyncTask<String, String, String> AsyncTask1;
			JSONArray JsonArr;
			JSONObject JSONOBJ;
			LatLng despoint;
			PostSvnEmer task1 = new PostSvnEmer();
			// task.setdata();
			task1.curpointemer(curlat, curlng,myMap);
			AsyncTask1 = task1.postter1
					.execute("http://192.168.1.101/myexample/mytest1.php");
			
		 }
	 

        public void recdatanormal(double _lat,double _lng,double curlat,double curlng,GoogleMap Map){
			Log.d("_lat",""+_lat);
			LatLng curpoint = new LatLng(curlat, curlng);
			LatLng despoint= new LatLng(_lat, _lng);
			Log.d("despoint",""+despoint);
			Log.d("curpoint",""+curpoint);
			Log.d("Map",""+Map);
			Router routerr1 = new Router(Map, curpoint, despoint);
			
		}
	 

	 public void posternormal (double curlat,double curlng) {
			AsyncTask<String, String, String>  AsyncTask2;
			PosterNormal posternormal = new PosterNormal();
			posternormal.PosterNormal(latchange, lngchange,getvalueintent);
			AsyncTask2 = posternormal.httppostnormal.execute("http://192.168.1.101/myexample/normalpost.php");
	 
	 
	 }
}
